1. Field of the Invention
The present invention relates to an improved data processing system and, in particular, to a method and apparatus for memory initialization.
2. Description of Related Art
An on-demand page-based virtual memory operation system, such as most UNIX™ operating systems, allocates page frames dynamically as needed. When a thread references a virtual page that does not have a page frame, a page fault is generated, and the operating system dynamically allocates a page frame. During the allocation of a page frame, the operating system must initialize the page.
A page initialization operation usually consists of either a zeroing-type or a copying-type of initialization. During a zeroing-type of initialization, the entire page frame is zeroed, e.g., following a first reference to a new virtual page. During a copying-type of initialization, the contents of a previously allocated virtual page are copied to the page frame that is being allocated, e.g., following a copy-on-write fork operation.
These page-zero and page-copy operations are done at interrupt-level while servicing the page fault. Hence, while the page initialization is being performed, no other thread can be dispatched on the CPU, and no lower-priority interrupts can be serviced. Usually this is not a problem because most operating systems are deployed to support small page sizes, and the amount of time that is required for a page initialization operation is relatively small.
For large pages, however, the time spent disabled at interrupt-level on a CPU while initializing a page frame can be problematic. For example, lower priority interrupts can be lost. In addition, thread dispatching can be impeded, particularly when a page initialization operation requires more time than a typical time slice that is provided by a thread scheduler. Noticeable slowdowns in performance may also be observed by users of a system.
As the price of memory decreases, more memory is added to data processing systems, and processors are being implemented to support larger page sizes, thereby leading to more frequent problems caused by page initialization operations. Rather than perform page initialization operations at interrupt-level and incur the penalties that have been mentioned above, other prior art solutions have been attempted.
One prior art solution performs page initialization operations more statically. Rather than faulting pages into an application's address space as the pages are referenced, all of the pages that might be needed by a process are initialized when the process is initialized, thereby avoiding page initialization operations in an interrupt environment at page-fault time. However, this solution moves away from an on-demand paging system and can introduce severe restrictions on the amount of memory that can be referenced. The initialization procedure may be quite lengthy since a large amount of memory must be initialized at one time, and much of this memory may never be referenced by a process.
Another prior art solution performs the page initialization operations in a piece-wise fashion using chunks that are smaller than the page size. On the first reference fault of a page frame, the entire page frame is allocated, but rather than initializing the entire page frame, only a chunk of the page frame is initialized. However, this solution is limited to software-managed translation lookaside buffer (TLB) architectures. After every chunk of the larger page frame has been referenced and initialized, then all of the chunk-sized translations are removed, and one translation is entered for the entire page frame. This solution introduces a number of penalties. Specifically, a page fault must be incurred for each chunk; for a 16 megabyte page frame with 4 kilobyte chunks, 4096 page faults would be incurred to initialize the entire page frame. Another drawback is that the page frame is translated on a chunk-size basis until the entire page frame is initialized, and any performance gains from using a large page translation are not achieved until all of the smaller chunks in the page frame have been initialized.
Therefore, it would be advantageous to perform page initialization operations much more efficiently while alleviating the problems that are mentioned above.